package cn.llming.auth.controller;



import cn.llming.auth.domain.RoleMenu;
import cn.llming.auth.domain.SystemPermission;
import cn.llming.auth.query.PermissionQuery;
import cn.llming.auth.service.IPermissionScanService;
import cn.llming.auth.service.IPermissionService;
import cn.llming.auth.util.BasePermission;
import cn.llming.basic.query.BaseQuery;
import cn.llming.vo.result.AjaxResult;
import cn.llming.vo.result.ListPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.ws.Action;
import java.util.List;

@RestController
@BasePermission(name = "权限管理")
@RequestMapping("/permission")
public class SystemPermissionController  {



    @Autowired
    private IPermissionService permissionService;
    @PostMapping
    @BasePermission(name = "分页查询接口")
    public AjaxResult getPageList(@RequestBody BaseQuery query){
        try {
            ListPage<SystemPermission> listPage=permissionService.getPageList(query);

            return AjaxResult.myRes().setObject(listPage);
        }catch (Exception e){
            return AjaxResult.myRes().setSuccess(false).setMessage("分页查询失败"+e.getMessage());
        }
    }

//权限树接口
    @GetMapping
    @BasePermission(name = "权限树查询接口")
    public AjaxResult getTree(){
        try {
            List<SystemPermission> lists=permissionService.getTree();

            return AjaxResult.myRes().setObject(lists);
        }catch (Exception e){
            return AjaxResult.myRes().setSuccess(false).setMessage("权限树查询失败"+e.getMessage());
        }
    }
//获取所有权限sn
    @GetMapping("/getSn")
    @BasePermission(name = "获取所有权限sn接口")
    public AjaxResult getSns(){
        try {
            List<String> strs=permissionService.getSns();

            return AjaxResult.myRes().setObject(strs);
        }catch (Exception e){
            return AjaxResult.myRes().setSuccess(false).setMessage("获取所有权限sn查询失败"+e.getMessage());
        }
    }








}
